/* osgEarth
 * Copyright 2025 Pelican Mapping
 * MIT License
 */
#pragma once

#include <osgEarth/Cache>

namespace osgEarth
{
    /**
     * An in-memory cache.
     * Each bin in this cache has its own locking mechanism for thread-safety. Each
     * bin also maintains an LRU list for maintaining the size cap.
     */
    class OSGEARTH_EXPORT MemCache : public Cache
    {
    public:
        MemCache( unsigned maxBinSize =16 );
        META_Object( osgEarth, MemCache );


    public: // Cache interface

        CacheBin* addBin(const std::string& binID) override;

        CacheBin* getOrCreateDefaultBin() override;
    
    private:
        MemCache( const MemCache& rhs, const osg::CopyOp& op =osg::CopyOp::DEEP_COPY_ALL ) 
         : Cache( rhs, op ) 
         , _maxBinSize(rhs._maxBinSize)
        { }

        unsigned _maxBinSize;
    };

} // namespace osgEarth
