Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gutyán Gábor
/
circlestack
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
99906aeb
authored
Aug 15, 2014
by
Őry Máté
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
common: use update_wrapper on cached method
parent
026be873
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
1 deletions
+7
-1
circle/common/models.py
+7
-1
No files found.
circle/common/models.py
View file @
99906aeb
...
@@ -17,6 +17,7 @@
...
@@ -17,6 +17,7 @@
from
collections
import
deque
from
collections
import
deque
from
contextlib
import
contextmanager
from
contextlib
import
contextmanager
from
functools
import
update_wrapper
from
hashlib
import
sha224
from
hashlib
import
sha224
from
itertools
import
chain
,
imap
from
itertools
import
chain
,
imap
from
logging
import
getLogger
from
logging
import
getLogger
...
@@ -233,9 +234,11 @@ def method_cache(memcached_seconds=60, instance_seconds=5): # noqa
...
@@ -233,9 +234,11 @@ def method_cache(memcached_seconds=60, instance_seconds=5): # noqa
def
inner_cache
(
method
):
def
inner_cache
(
method
):
method_name
=
method
.
__name__
def
get_key
(
instance
,
*
args
,
**
kwargs
):
def
get_key
(
instance
,
*
args
,
**
kwargs
):
return
sha224
(
unicode
(
method
.
__module__
)
+
return
sha224
(
unicode
(
method
.
__module__
)
+
unicode
(
method
.
__name__
)
+
method_name
+
unicode
(
instance
.
id
)
+
unicode
(
instance
.
id
)
+
unicode
(
args
)
+
unicode
(
args
)
+
unicode
(
kwargs
))
.
hexdigest
()
unicode
(
kwargs
))
.
hexdigest
()
...
@@ -269,6 +272,9 @@ def method_cache(memcached_seconds=60, instance_seconds=5): # noqa
...
@@ -269,6 +272,9 @@ def method_cache(memcached_seconds=60, instance_seconds=5): # noqa
unicode
(
args
),
unicode
(
result
))
unicode
(
args
),
unicode
(
result
))
return
result
return
result
update_wrapper
(
x
,
method
)
x
.
_original
=
method
return
x
return
x
return
inner_cache
return
inner_cache
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment