修改8.25 get_spam格式

This commit is contained in:
chim
2019-05-13 11:26:43 +08:00
parent 08304536f1
commit 4de0abd467
2 changed files with 6 additions and 6 deletions

View File

@@ -2,7 +2,7 @@
# -*- encoding: utf-8 -*-
"""
Topic: 创建缓存实例
Desc :
Desc :
"""
import logging
@@ -78,8 +78,8 @@ class Spam2:
def __init__(self, name):
self.name = name
def get_spam(name):
return Spam2.manager.get_spam(name)
def get_spam(name):
return Spam2.manager.get_spam(name)
# ------------------------最后的修正方案------------------------
@@ -114,4 +114,4 @@ print('------------------------------')
cachedSpamManager = CachedSpamManager2()
s = cachedSpamManager.get_spam('Dave')
t = cachedSpamManager.get_spam('Dave')
print(s is t)
print(s is t)

View File

@@ -147,8 +147,8 @@
def __init__(self, name):
self.name = name
def get_spam(name):
return Spam.manager.get_spam(name)
def get_spam(name):
return Spam.manager.get_spam(name)
这样的话代码更清晰并且也更灵活我们可以增加更多的缓存管理机制只需要替代manager即可。