Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Get API which returns additional information about the entry #168

Merged
merged 2 commits into from
Oct 1, 2019

Conversation

jgheewala
Copy link
Contributor

enhancement: added new data struct Response, which will be returned when
calling GetWithInfo(). Caller can use this Response to check the status
of the Entry, whether its Expired or not. Default '0' means its still
in use.

minor lint changes

Test: added test case for the api and made sure all tests cases are
successful

caches_bench/caches_bench_test.go Outdated Show resolved Hide resolved
bigcache.go Outdated Show resolved Hide resolved
bigcache.go Outdated Show resolved Hide resolved
Copy link
Collaborator

@siennathesane siennathesane left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will need functional tests as well. :)

@coveralls
Copy link

coveralls commented Sep 24, 2019

Coverage Status

Coverage remained the same at 92.02% when pulling c5ea4ea on jgheewala:get_api_info into 3bd7858 on allegro:master.

@jgheewala
Copy link
Contributor Author

@mxplusb I forgot to add my test cases. Sorry about that. Have added it now.

entry_not_found_error.go Outdated Show resolved Hide resolved
shard.go Outdated Show resolved Hide resolved
shard.go Show resolved Hide resolved
siennathesane
siennathesane previously approved these changes Sep 29, 2019
Copy link
Collaborator

@siennathesane siennathesane left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm okay with this. It's well covered with tests, it's a new API, and it has benchmarks. I can't think of a reason not to add this.

Copy link
Collaborator

@janisz janisz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have only minor styling comments. Then we can merge it.

shard.go Show resolved Hide resolved
shard.go Outdated Show resolved Hide resolved
bigcache.go Outdated Show resolved Hide resolved
enhancement: added new data struct Response, which will be returned when
calling GetWithInfo(). Caller can use this Response to check the status
of the Entry, whether its Expired or not. Default '0' means its still
in use.

Test: added test case for the api and made sure all tests cases are
successful. made sure that testing is above par level

BenchMarkCompare old (master) & new (get_api_info)

benchmark                                                       old allocs     new allocs     delta
BenchmarkWriteToCacheWith1Shard-12                              3              3              +0.00%
BenchmarkWriteToLimitedCacheWithSmallInitSizeAnd1Shard-12       3              3              +0.00%
BenchmarkWriteToUnlimitedCacheWithSmallInitSizeAnd1Shard-12     2              2              +0.00%
BenchmarkWriteToCache/1-shards-12                               3              3              +0.00%
BenchmarkWriteToCache/512-shards-12                             3              3              +0.00%
BenchmarkWriteToCache/1024-shards-12                            3              3              +0.00%
BenchmarkWriteToCache/8192-shards-12                            3              3              +0.00%
BenchmarkReadFromCache/1-shards-12                              2              2              +0.00%
BenchmarkReadFromCache/512-shards-12                            2              2              +0.00%
BenchmarkReadFromCache/1024-shards-12                           2              2              +0.00%
BenchmarkReadFromCache/8192-shards-12                           2              2              +0.00%
BenchmarkIterateOverCache/512-shards-12                         2              2              +0.00%
BenchmarkIterateOverCache/1024-shards-12                        2              2              +0.00%
BenchmarkIterateOverCache/8192-shards-12                        2              2              +0.00%
BenchmarkWriteToCacheWith1024ShardsAndSmallShardInitSize-12     3              3              +0.00%
BenchmarkReadFromCacheNonExistentKeys/1-shards-12               0              0              +0.00%
BenchmarkReadFromCacheNonExistentKeys/512-shards-12             0              0              +0.00%
BenchmarkReadFromCacheNonExistentKeys/1024-shards-12            0              0              +0.00%
BenchmarkReadFromCacheNonExistentKeys/8192-shards-12            0              0              +0.00%

benchmark                                                       old bytes     new bytes     delta
BenchmarkWriteToCacheWith1Shard-12                              579           579           +0.00%
BenchmarkWriteToLimitedCacheWithSmallInitSizeAnd1Shard-12       41            41            +0.00%
BenchmarkWriteToUnlimitedCacheWithSmallInitSizeAnd1Shard-12     3448          3448          +0.00%
BenchmarkWriteToCache/1-shards-12                               579           579           +0.00%
BenchmarkWriteToCache/512-shards-12                             574           573           -0.17%
BenchmarkWriteToCache/1024-shards-12                            574           574           +0.00%
BenchmarkWriteToCache/8192-shards-12                            579           579           +0.00%
BenchmarkReadFromCache/1-shards-12                              271           271           +0.00%
BenchmarkReadFromCache/512-shards-12                            271           271           +0.00%
BenchmarkReadFromCache/1024-shards-12                           271           271           +0.00%
BenchmarkReadFromCache/8192-shards-12                           271           271           +0.00%
BenchmarkIterateOverCache/512-shards-12                         20            20            +0.00%
BenchmarkIterateOverCache/1024-shards-12                        20            20            +0.00%
BenchmarkIterateOverCache/8192-shards-12                        20            20            +0.00%
BenchmarkWriteToCacheWith1024ShardsAndSmallShardInitSize-12     1154          1154          +0.00%
BenchmarkReadFromCacheNonExistentKeys/1-shards-12               7             7             +0.00%
BenchmarkReadFromCacheNonExistentKeys/512-shards-12             7             7             +0.00%
BenchmarkReadFromCacheNonExistentKeys/1024-shards-12            7             7             +0.00%
BenchmarkReadFromCacheNonExistentKeys/8192-shards-12            7             7             +0.00%

Benchmarking Result:

GOROOT=/usr/local/Cellar/go@1.12/1.12.9/libexec #gosetup
GOPATH=/Users/jaygheewala/.go #gosetup
/usr/local/Cellar/go@1.12/1.12.9/libexec/bin/go test -c -o /private/var/folders/tr/0xbgwcsn60l6j_64qlfdxztm0000gp/T/___gobench_github_com_allegro_bigcache_v2 github.com/allegro/bigcache/v2 #gosetup
/private/var/folders/tr/0xbgwcsn60l6j_64qlfdxztm0000gp/T/___gobench_github_com_allegro_bigcache_v2 -test.v -test.bench . -test.run ^$ #gosetup
goos: darwin
goarch: amd64
pkg: github.com/allegro/bigcache/v2
BenchmarkWriteToCacheWith1Shard-12                             	 2000000	       694 ns/op	     579 B/op	       3 allocs/op
BenchmarkWriteToLimitedCacheWithSmallInitSizeAnd1Shard-12      	 3000000	       449 ns/op	      41 B/op	       3 allocs/op
BenchmarkWriteToUnlimitedCacheWithSmallInitSizeAnd1Shard-12    	 1000000	      1670 ns/op	    3448 B/op	       2 allocs/op
BenchmarkWriteToCache/1-shards-12                              	 2000000	       574 ns/op	     579 B/op	       3 allocs/op
BenchmarkWriteToCache/512-shards-12                            	10000000	       164 ns/op	     573 B/op	       3 allocs/op
BenchmarkWriteToCache/1024-shards-12                           	10000000	       151 ns/op	     574 B/op	       3 allocs/op
BenchmarkWriteToCache/8192-shards-12                           	10000000	       186 ns/op	     579 B/op	       3 allocs/op
BenchmarkReadFromCache/1-shards-12                             	 5000000	       324 ns/op	     271 B/op	       2 allocs/op
BenchmarkReadFromCache/512-shards-12                           	 5000000	       330 ns/op	     271 B/op	       2 allocs/op
BenchmarkReadFromCache/1024-shards-12                          	 5000000	       329 ns/op	     271 B/op	       2 allocs/op
BenchmarkReadFromCache/8192-shards-12                          	 5000000	       323 ns/op	     271 B/op	       2 allocs/op
BenchmarkReadFromCacheWithInfo/1-shards-12                     	 5000000	       326 ns/op	     271 B/op	       2 allocs/op
BenchmarkReadFromCacheWithInfo/512-shards-12                   	 5000000	       330 ns/op	     271 B/op	       2 allocs/op
BenchmarkReadFromCacheWithInfo/1024-shards-12                  	 5000000	       327 ns/op	     271 B/op	       2 allocs/op
BenchmarkReadFromCacheWithInfo/8192-shards-12                  	 5000000	       322 ns/op	     271 B/op	       2 allocs/op
BenchmarkIterateOverCache/512-shards-12                        	10000000	       244 ns/op	      20 B/op	       2 allocs/op
BenchmarkIterateOverCache/1024-shards-12                       	10000000	       237 ns/op	      20 B/op	       2 allocs/op
BenchmarkIterateOverCache/8192-shards-12                       	10000000	       220 ns/op	      20 B/op	       2 allocs/op
BenchmarkWriteToCacheWith1024ShardsAndSmallShardInitSize-12    	10000000	       355 ns/op	    1154 B/op	       3 allocs/op
BenchmarkReadFromCacheNonExistentKeys/1-shards-12              	10000000	       185 ns/op	       8 B/op	       0 allocs/op
BenchmarkReadFromCacheNonExistentKeys/512-shards-12            	10000000	       191 ns/op	       7 B/op	       0 allocs/op
BenchmarkReadFromCacheNonExistentKeys/1024-shards-12           	10000000	       189 ns/op	       7 B/op	       0 allocs/op
BenchmarkReadFromCacheNonExistentKeys/8192-shards-12           	10000000	       190 ns/op	       7 B/op	       0 allocs/op
BenchmarkFnvHashSum64-12                                       	200000000	         8.66 ns/op
BenchmarkFnvHashStdLibSum64-12                                 	50000000	        38.3 ns/op
PASS
Copy link
Collaborator

@cristaloleg cristaloleg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@cristaloleg cristaloleg merged commit 0bb712d into allegro:master Oct 1, 2019
@cristaloleg
Copy link
Collaborator

Thank you @jgheewala

flisky pushed a commit to flisky/bigcache that referenced this pull request May 7, 2020
…egro#168)

enhancement: added new data struct Response, which will be returned when
calling GetWithInfo(). Caller can use this Response to check the status
of the Entry, whether its Expired or not. Default '0' means its still
in use.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants