Revisions
-
skyl revised this gist
May 26, 2010 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -16,9 +16,9 @@ class Blog(models.Model, DredisMixin): # inherit from the mixin class 1 >>> blog.viewcount.incr(5) 6 >>> blog.myzset <SortedSet: []> >>> blog.myzset.add('foo', 10) True >>> blog.myzset <SortedSet: ['foo']> -
skyl revised this gist
May 26, 2010 . 1 changed file with 12 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,14 +1,24 @@ from djredis.models import DredisMixin import djredis.models class Blog(models.Model, DredisMixin): # inherit from the mixin class author = models.ForeignKey('Author') title = models.CharField(max_length=200) # declaratively add your redis fields viewcount = djredis.models.Counter() myzset = djredis.models.Zset() >>> blog = Blog.objects.get(pk=1) >>> blog.viewcount.incr() 1 >>> blog.viewcount.incr(5) 6 >>> c.myzset <SortedSet: []> >>> c.myzset.add('foo', 10) True >>> c.myzset <SortedSet: ['foo']> -
skyl revised this gist
May 26, 2010 . 1 changed file with 5 additions and 7 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -6,11 +6,9 @@ class Blog(models.Model, DredisMixin): # inherit from the mixin class title = models.CharField(max_length=200) viewcount = djredis.fields.Counter() >>> blog = Blog.objects.get(pk=1) >>> blog.viewcount.incr() 1 >>> blog.viewcount.incr(5) 6 -
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4,7 +4,7 @@ class Blog(models.Model, DredisMixin): # inherit from the mixin class author = models.ForeignKey('Author') title = models.CharField(max_length=200) viewcount = djredis.fields.Counter() # optionally add a unique keyspace for the instance - default is shown below def redis_key(self): -
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,16 @@ from djredis.models import DredisMixin import djredis.fields class Blog(models.Model, DredisMixin): # inherit from the mixin class author = models.ForeignKey('Author') title = models.CharField(max_length=200) viewcount = djredis.fields.IntegerField() # optionally add a unique keyspace for the instance - default is shown below def redis_key(self): return '%s:%s:%s' % (self._meta.app_label, self._meta.module_name, self.pk) blog = Blog.objects.get(pk=1) blog.viewcount.incr() # or equivalently: blog.viewcount += 1