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

SSDB + delete items by Tag #411

Closed
git-webmaster opened this issue Jan 4, 2017 · 21 comments
Closed

SSDB + delete items by Tag #411

git-webmaster opened this issue Jan 4, 2017 · 21 comments

Comments

@git-webmaster
Copy link
Contributor

###Configuration:

PhpFastCache version: 5.0.12
PHP version: 7.0.14 x64 NTS
Operating system: Debian 8 x64

SSDB version: Ssdb-server v1.9.4

####Issue description:

Hi again.
I use code below to delete items by tags:

$pfc_instance->deleteItemsByTag($key);

or by key:

$pfc_instance->deleteItem($key);

Both of this methods are not working with SSDB in my case.
When i switch driver to "files" or "sqlite", all things work as expected.

When on SSDB i am able only to run:

$pfc_instance->clear();

And clear all cache data, but in my case this is not acceptable at all.
Will you please check and confirm this issue?

@git-webmaster git-webmaster changed the title SSDB delete item by Tag SSDB + delete items by Tag Jan 4, 2017
@git-webmaster
Copy link
Contributor Author

git-webmaster commented Jan 4, 2017

I use code below to set tags (2 tags for this key):

$pfc_html->set($pfc_compressed_page)->expiresAfter(315360000)->addTags([$domain['cache_tag'], 'category']);

@git-webmaster
Copy link
Contributor Author

git-webmaster commented Jan 4, 2017

ssdb logs:

  1. Creating 2 objects with keys //example.com/c/united-states/ca/los-angeles/cafes (1), //example.com/c/united-states/ca/los-angeles/bakeries (2) (thats an comressed html page) with tags ['los-angeles/cafes', 'category'] (1) and ['los-angeles/bakeries', 'category'] (2):
2017-01-04 19:37:30.699 [DEBUG] server.cpp(246): new link from 127.0.0.1:58016, fd: 18, links: 1
2017-01-04 19:37:30.700 [DEBUG] server.cpp(340): w:0.021,p:1.063, req: flushdb kv, resp: ok
2017-01-04 19:37:30.700 [DEBUG] server.cpp(415): fd: 18, read: 0, delete link, s:0.001
2017-01-04 19:37:36.247 [DEBUG] server.cpp(246): new link from 127.0.0.1:58018, fd: 18, links: 1
2017-01-04 19:37:36.248 [DEBUG] server.cpp(340): w:0.049,p:0.019, req: get //example.com/c/united-states/ca/los-angeles/cafes, resp: not_found
2017-01-04 19:37:37.264 [DEBUG] server.cpp(340): w:0.040,p:0.164, req: setx [51] [15346] 1798907857, resp: ok 1
2017-01-04 19:37:37.264 [DEBUG] server.cpp(340): w:0.039,p:0.012, req: get _TAG_los-angeles/cafes, resp: not_found
2017-01-04 19:37:37.265 [DEBUG] server.cpp(340): w:0.015,p:0.010, req: get _TAG_category, resp: not_found
2017-01-04 19:37:37.265 [DEBUG] server.cpp(340): w:0.034,p:0.060, req: setx _TAG_los-angeles/cafes [228] 1798907857, resp: ok 1
2017-01-04 19:37:37.265 [DEBUG] server.cpp(340): w:0.008,p:0.050, req: setx _TAG_category [228] 1798907857, resp: ok 1
2017-01-04 19:37:37.271 [DEBUG] server.cpp(415): fd: 18, read: 0, delete link, s:1.023
2017-01-04 19:37:43.108 [DEBUG] server.cpp(246): new link from 127.0.0.1:58020, fd: 18, links: 1
2017-01-04 19:37:43.108 [DEBUG] server.cpp(340): w:0.024,p:0.041, req: get //example.com/c/united-states/ca/los-angeles/bakeries, resp: not_found
2017-01-04 19:37:43.870 [DEBUG] server.cpp(340): w:0.018,p:0.182, req: setx [54] [15980] 1798907863, resp: ok 1
2017-01-04 19:37:43.871 [DEBUG] server.cpp(340): w:0.031,p:0.021, req: get _TAG_los-angeles/bakeries, resp: not_found
2017-01-04 19:37:43.871 [DEBUG] server.cpp(340): w:0.017,p:0.011, req: get _TAG_category, resp: ok [228]
2017-01-04 19:37:43.871 [DEBUG] server.cpp(340): w:0.009,p:0.059, req: setx _TAG_los-angeles/bakeries [231] 1798907863, resp: ok 1
2017-01-04 19:37:43.871 [DEBUG] server.cpp(340): w:0.009,p:0.042, req: setx _TAG_category [303] 1798907863, resp: ok 1
2017-01-04 19:37:43.878 [DEBUG] server.cpp(415): fd: 18, read: 0, delete link, s:0.770
  1. Trying to delete them using tag "category":
2017-01-04 19:38:50.677 [DEBUG] server.cpp(246): new link from 127.0.0.1:58022, fd: 18, links: 1
2017-01-04 19:38:50.678 [DEBUG] server.cpp(340): w:0.040,p:0.024, req: get _TAG_category, resp: ok [303]
2017-01-04 19:38:50.678 [DEBUG] server.cpp(340): w:0.040,p:0.024, req: get //example.com/c/united-states/ca/los-angeles/cafes, resp: ok [15346]
2017-01-04 19:38:50.678 [DEBUG] server.cpp(340): w:0.074,p:0.034, req: get //example.com/c/united-states/ca/los-angeles/bakeries, resp: ok [15980]
2017-01-04 19:38:50.679 [ERROR] t_zset.cpp(341): key too long!
2017-01-04 19:38:50.679 [DEBUG] server.cpp(340): w:0.020,p:0.288, req: del [15137], resp: ok 1
2017-01-04 19:38:50.679 [ERROR] t_zset.cpp(341): key too long!
2017-01-04 19:38:50.680 [DEBUG] server.cpp(340): w:0.021,p:0.264, req: del [15768], resp: ok 1
2017-01-04 19:38:50.680 [DEBUG] server.cpp(415): fd: 18, read: 0, delete link, s:0.002

As you can see, there are errors:

2017-01-04 19:38:50.679 [ERROR] t_zset.cpp(341): key too long!
2017-01-04 19:38:50.679 [ERROR] t_zset.cpp(341): key too long!

Result: delete fails, objects are still in cache.

@git-webmaster
Copy link
Contributor Author

According to http://ssdb.io/docs/limit.html - Max key length 200 bytes
But, as far as i understand "Tag" is a "value", which is - Max value length 31MB

Will you please clarify what should i do in order not to get this error?
How do you implemented TAG search and structure in terms of key-value?

Thanks!

@Geolim4
Copy link
Member

Geolim4 commented Jan 4, 2017 via email

@git-webmaster
Copy link
Contributor Author

git-webmaster commented Jan 4, 2017

Thanks, hope we will resolve this issue.
One more thing:

Just tried to use md5(url) as key (md5 always has length = 32 symbols) (which is less then 200 bytes SSDB key limit).

But nothing changes: create: setx() - resp: ok 1, delete fails with [ERROR] t_zset.cpp(341): key too long!

@Geolim4
Copy link
Member

Geolim4 commented Jan 4, 2017

I'm gonna install Ssdb soon, hang tight :)

@Geolim4
Copy link
Member

Geolim4 commented Jan 4, 2017

The MD5 clue seems to be a valid one, I'm testing some things.
I'm wondering how to add this to unit tests as Travis does not support Ssdb :(

@Geolim4
Copy link
Member

Geolim4 commented Jan 4, 2017

Found it, I'm a damn idiot, the 32 chars limitation is not the only one issue:
https://github.com/PHPSocialNetwork/phpfastcache/blob/final/src/phpFastCache/Drivers/Ssdb/Driver.php#L118

I'm calling $item->get() instead of $item->getKey()

....

@Geolim4 Geolim4 closed this as completed in 1fdda2c Jan 4, 2017
Geolim4 added a commit that referenced this issue Jan 4, 2017
- Removed unused method encodeFilename() on DriverBaseTrait
- Fixed #411
@Geolim4 Geolim4 reopened this Jan 4, 2017
@Geolim4
Copy link
Member

Geolim4 commented Jan 4, 2017

I added a fix on final branch, try it :)

@git-webmaster
Copy link
Contributor Author

Lightning fast :)

Will now check it, and respond.

Geolim4 added a commit that referenced this issue Jan 4, 2017
@Geolim4
Copy link
Member

Geolim4 commented Jan 4, 2017

V6 is now patched too.

@git-webmaster
Copy link
Contributor Author

Work as expected, issue closed.
Will you please update packagist? I want to update my production server using composer.

p.s.

thanks for being so fast to resolve bugs :)
Much appreciated

@Geolim4
Copy link
Member

Geolim4 commented Jan 4, 2017

I'll release tonigh :)

@git-webmaster
Copy link
Contributor Author

Thank you!
Closing issue.

@Geolim4
Copy link
Member

Geolim4 commented Jan 4, 2017

5.0.13 release is out :)

@git-webmaster
Copy link
Contributor Author

Hi, reopened issue due to this:

Updated my production server with composer to v. 5.0.13, and cache cleaning by tag does not seems to be working.

Looked into local sources, that i got from composer (packagist):

    protected function driverDelete(CacheItemInterface $item)
    {
.....
            return $this->instance->del($item->get());
.....
    }

while here in github actual is:

    protected function driverDelete(CacheItemInterface $item)
    {
....
            return $this->instance->del($item->getEncodedKey());
.....
    }

Please, update packagist with current, actual version.
I use composer to update all packages, and i can't make this changes manually - they will be rewrited after next update.
Thank you.

@git-webmaster git-webmaster reopened this Jan 9, 2017
@git-webmaster
Copy link
Contributor Author

According to https://packagist.org/packages/phpfastcache/phpfastcache#5.0.13, its package was uploaded 2017-01-01, while this isuue was resolved at 2017-01-04.

@git-webmaster
Copy link
Contributor Author

Also:
Do you recommend to use "phpFastCache/phpFastCache": "^6.0" with ssdb driver in production, or not?

@Geolim4
Copy link
Member

Geolim4 commented Jan 9, 2017

Hello @git-webmaster

I think I made a mistake on the git tag, I will release a 5.0.14 tonight with the right commit target.
It will also fix another bug with Predis driver.

The V6 is still in beta state for now, but a stable release should be out in the next 2 months.

Cheers,
georges

@Geolim4
Copy link
Member

Geolim4 commented Jan 9, 2017

@git-webmaster
Copy link
Contributor Author

Thanks, Georges!
Will check later, and reopen if any issues occurred.
Now closing this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants