Closed (fixed)
Project:
Drush
Component:
Core Commands
Priority:
Normal
Category:
Feature request
Assigned:
Reporter:
Created:
11 Feb 2011 at 21:22 UTC
Updated:
18 Apr 2011 at 21:31 UTC
Jump to comment: Most recent file
It would be really handy to be able to easily run cache_get from drush. Just connecting to the database / cache backend isn't enough, as usually objects are serialized and need PHP to unserialize them. Attached is a patch that implements a cache-get command:
$ drush4 cache-get --help
Fetch a cached object and display it.
Examples:
drush cache-get schema Display the data for the cache id "schema" from the "cache" bin.
drush cache-get Display the data for the cache id "update_available_releases" from the "update" bin.
update_available_releases update
Arguments:
cid The id of the object to fetch.
bin Optional. The cache bin to fetch from.
Aliases: cgThe attache patch applies to both the 5.x and 4.x branches.
| Comment | File | Size | Author |
|---|---|---|---|
| #21 | 1059112.cache-get-set-21.patch | 10.7 KB | deviantintegral |
| #19 | 1059112.cache-get-set-19.patch | 10.7 KB | deviantintegral |
| #18 | 1059112.cache-get-set-18.patch | 10.65 KB | msonnabaum |
| #16 | 1059112.cache-get-set-16.patch | 10.89 KB | deviantintegral |
| #14 | 1059112.cache-get-set-14.patch | 11.54 KB | msonnabaum |
Comments
Comment #1
msonnabaum commentedSeems pretty useful to me.
My only note is that I'd rather see the object returned as JSON than use drush_print_r(). That way you could possibly do something with the object rather than just view it.
Comment #2
msonnabaum commentedOh and also, if we're going to do this, we need more than just "get".
I'm thinking this patch should probably turn clear.cache.inc into cache.drush.inc where cache clearing and getting/setting is all together.
Comment #3
greg.1.anderson commentedYes, I agree, but I think that in general, var_export is more readable than JSON. Maybe add in a flag so that the caller can select the output format?
As far as doing something with the object, if you return the object as the result of the command hook, then it will be available in $result['object'] when called via backend invoke (if there is a use case for remotely fetching cache values... :> ).
Comment #4
msonnabaum commentedYeah, JSON probably isn't good for default output, especially considering php doesn't really have a good pretty print option for it.
I'd be cool with a JSON flag like I did for node-show: #1005480: Create a new project to develop Drush entity support.
And just having come off a project that made heavy use of a SOAP backend and caching all of the SOAP responses, I can say that there is definitely a use case for remotely fetching those objects.
Comment #5
deviantintegral commentedAgreed about adding more cache_* commands and unifying them in one file. Strangely enough, I'm also working on a project involving SOAP and caching, hence why I was wanting an easy way to query our local cache.
Here's a patch that simply adds --json as a flag.
Comment #6
deviantintegral commentedHere's a patch that expands the cache functionality.
I didn't add import support for var_export() output as PHP doesn't have a stdClass::__setState() method.
Current patch applies identically to 4.x and 5.x.
Comment #7
moshe weitzman commentedLooks great.
Comment #8
moshe weitzman commentedHope someone can finish this off. It is close.
Comment #9
kotnik commentedHere's the patch that applies to HEAD with fixes from #7.
Comment #10
kotnik commentedPlease review.
Comment #11
kotnik commentedUpdated patch (I wrongly set lower bootstrap for cache-clear).
Comment #12
moshe weitzman commentedLooks good. I read the patches in order and so composed the following review which is now deprecated because your second commit in the patch fixes the problem. I really think we should post a single squashed commit to the issue queue. What would be the patch authoring process for that?
The patch is RTBC IMO. Will leave it open for a bit in case more comments come along.
This function is in common.inc which is not included until FULL. I don't see how this can be working.
I'm similarly worried that this function won't return same results as FULL.
maybe cc command should stay as full.
Comment #13
deviantintegral commentedI can't seem to apply either of the previous patches. They both reference commish 3953f1fe51b381eff7c10f10249c3ea9f8582cc4, which isn't in my tree.
To generate a single patch, just do "git diff master".
Comment #14
msonnabaum commentedTry this one, which squashes the two commits into one.
Comment #15
kotnik commentedDevianintegral, try Msonnabaum's patch. Mine were created against Drush master branch.
Comment #16
deviantintegral commentedI could only apply #14 by using patch. It looks like it was generated with --no-prefix, which I doesn't seem to work well with applying.
The JSON functions don't work without a full bootstrap, at least on D6. I think we do have to stick with a full bootstrap for this. Here's a patch with just the bootstrap keys removed.
Comment #17
msonnabaum commentedI've just added two new functions in master: drush_json_encode and drush_json_decode.
I'd like to get rid of the environment specific logic around the json handling, so lets just use these instead.
Comment #18
msonnabaum commentedHere's a patch with the changes I suggested. I can't seem to get it to work cleanly using format-patch and am, so its just a regular git diff.
Comment #19
deviantintegral commentedThe patch in #18 was missing returns from the switch statement for cache get, so all formats were printed out instead of the selected one.
Comment #20
moshe weitzman commentedThis is probably ready. Will let Mark do the final look over and commits.
Comment #21
deviantintegral commentedHere's a reroll against master.
Comment #22
msonnabaum commentedOk, this is looking good enough for me.
Committed to master and backported to 4.
Comment #23
deviantintegral commentedSomething is wrong with the commit, as it only shows removing clear.cache.inc, and none of the other modifications. 7.x-4.x looks fine.
Comment #24
msonnabaum commentedGood call. Forgot to add the cache inc.