Lines Matching refs:id

44  * Usage examples; id is a String representation of a row id (_id), as it might be retrieved from
51 * Cursor cursor = cache.getCursor(id, projection);
54 * 1. Get a CacheToken: CacheToken token = cache.getToken(id);
56 * 3. Put the cursor in the cache: cache.putCursor(cursor, id, token);
60 * 1. Lock the row in the cache: cache.lock(id);
65 * 4. Unlock the row in the cache: cache.unlock(id);
68 * 1. Lock the row in the cache: cache.lock(id);
70 * 3. Unlock the row in the cache, passing in the new values: cache.unlock(id, values);
99 // A set of locked content id's
177 * A list of tokens that are in use at any moment; there can be more than one token for an id
187 /*package*/ int invalidateTokens(String id) {
189 LogUtils.d(mLogTag, "============ Invalidate tokens for: " + id);
194 if (token.getId().equals(id)) {
228 public CacheToken add(String id) {
229 CacheToken token = new CacheToken(id);
247 /*package*/ CacheToken(String id) {
248 mId = id;
293 public CachedCursor(Cursor cursor, ContentCache cache, String id) {
297 mId = id;
441 * Get a CacheToken for a row as specified by its id (_id column)
442 * @param id the id of the record
445 public synchronized CacheToken getCacheToken(String id) {
447 CacheToken token = mTokenList.add(id);
448 if (mLockMap.contains(id)) {
459 Cursor get(String id) {
460 return mLruCache.get(id);
467 * Try to cache a cursor for the given id and projection; returns a valid cursor, either a
471 * @param id the record id (_id) of the content
475 public Cursor putCursor(Cursor c, String id, String[] projection, CacheToken token) {
480 return putCursorImpl(c, id, projection, token);
482 public synchronized Cursor putCursorImpl(Cursor c, String id, String[] projection,
487 LogUtils.d(mLogTag, "============ Stale token for " + id);
494 LogUtils.d(mLogTag, "============ Caching cursor for: " + id);
497 Cursor existingCursor = get(id);
499 unlockImpl(id, null, false);
501 mLruCache.put(id, c);
502 return new CachedCursor(c, this, id);
511 * Find and, if found, return a cursor, based on cached values, for the supplied id
512 * @param id the _id column of the desired row
516 public synchronized Cursor getCachedCursor(String id, String[] projection) {
522 return getCachedCursorImpl(id);
524 return getMatrixCursor(id, projection);
528 private CachedCursor getCachedCursorImpl(String id) {
529 Cursor c = get(id);
532 return new CachedCursor(c, this, id);
538 private MatrixCursor getMatrixCursor(String id, String[] projection) {
539 return getMatrixCursor(id, projection, null);
542 private MatrixCursor getMatrixCursor(String id, String[] projection,
544 Cursor c = get(id);
590 * Lock a given row, such that no new valid CacheTokens can be created for the passed-in id.
591 * @param id the id of the row to lock
593 public synchronized void lock(String id) {
595 mLockMap.add(id);
597 int count = mTokenList.invalidateTokens(id);
600 " tokens for: " + id);
605 * Unlock a given row, allowing new valid CacheTokens to be created for the passed-in id.
606 * @param id the id of the item whose cursor is cached
608 public synchronized void unlock(String id) {
609 unlockImpl(id, null, true);
613 * If the row with id is currently cached, replaces the cached values with the supplied
616 * @param id the id of the item whose cursor is cached
619 public synchronized void unlock(String id, ContentValues values) {
620 unlockImpl(id, values, true);
628 * @param id the id of the row
632 private void unlockImpl(String id, ContentValues values, boolean wasLocked) {
633 Cursor c = get(id);
636 LogUtils.d(mLogTag, "=========== Unlocking cache for: " + id);
639 MatrixCursor cursor = getMatrixCursor(id, mBaseProjection, values);
642 LogUtils.d(mLogTag, "=========== Recaching with new values: " + id);
645 mLruCache.put(id, cursor);
647 mLruCache.remove(id);
650 mLruCache.remove(id);
658 mLockMap.subtract(id);