Package net.sf.ehcache.concurrent

Examples of net.sf.ehcache.concurrent.Sync.lock()


    /**
     * {@inheritDoc}
     */
    public boolean containsKeyInMemory(Object key) {
        Sync s = sync.getSyncForKey(key);
        s.lock(LockType.READ);
        try {
            return memory.containsKey(key);
        } finally {
            s.unlock(LockType.READ);
        }
View Full Code Here


    /**
     * {@inheritDoc}
     */
    public boolean containsKeyOnDisk(Object key) {
        Sync s = sync.getSyncForKey(key);
        s.lock(LockType.READ);
        try {
            if (disk != null) {
                return disk.containsKey(key);
            } else {
                return false;
View Full Code Here

     */
    public void expireElements() {
    
        for (Object key : memory.getKeys()) {
            Sync s = sync.getSyncForKey(key);
            s.lock(LockType.WRITE);
            try {
                Element element = memory.getQuiet(key);
                if (element != null) {
                    if (element.isExpired(config)) {
                        Element e = remove(key);
View Full Code Here

    /**
     * {@inheritDoc}
     */
    public Element get(Object key) {
        Sync s = sync.getSyncForKey(key);
        s.lock(LockType.READ);
        try {
            Element e = memory.get(key);
            if (e == null && disk != null) {
                e = disk.get(key);
                if (e != null) {
View Full Code Here

    /**
     * {@inheritDoc}
     */
    public Element getQuiet(Object key) {
        Sync s = sync.getSyncForKey(key);
        s.lock(LockType.READ);
        try {
            Element e = memory.getQuiet(key);
            if (e == null && disk != null) {
                e = disk.getQuiet(key);
                if (e != null) {
View Full Code Here

        if (element == null) {
            return false;
        }
       
        Sync s = sync.getSyncForKey(element.getObjectKey());
        s.lock(LockType.WRITE);
        try {
            boolean notOnDisk = !containsKeyOnDisk(element.getObjectKey());
            return memory.put(element) && notOnDisk;
        } finally {
            s.unlock(LockType.WRITE);
View Full Code Here

        Object value = element.getObjectValue();

        Sync lock = getLockForKey(key);
       
        if (!lock.isHeldByCurrentThread(LockType.WRITE)) {
            lock.lock(LockType.WRITE);
        }
        try {
            if (value != null) {
                underlyingCache.put(element);
            } else {
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.