Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @staticmethod
- def fetch(sgids):
- # Create a unique list.
- sgids = list(set(sgids))
- keys = map(lambda x: "Record.%s" % x, sgids)
- cached = cache.get_multi(keys)
- found = map(lambda x: cached[x]['sgid'], cached)
- diff = list(set(sgids) - set(found))
- parent = ColumnParent(column_family=Record.Meta.column_family)
- predicate = SlicePredicate(slice_range=SliceRange(start="",
- finish=""))
- if diff:
- res = get_pool(Record.Meta.keyspace).multiget_slice(
- Record.Meta.keyspace, diff, parent, predicate,
- ConsistencyLevel.ONE)
- cass = dict([(key, dict([(col.column.name, col.column.value) for
- col in cols])) for key, cols in res.iteritems()])
- cached.update(cass)
- ret = dict((rec['sgid'], Record(**rec)) for key, rec in cached.iteritems())
- map(lambda x: ret[x].cache(), diff)
Add Comment
Please, Sign In to add comment