UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'r+SyZtzTiV/aZZIbYe3v2Jjsio6SE2AcYwsFyihp+z0='
WHERE
key_id = 'aa99781cd020dbd70587651c7664b4dc69e5cdfb928aa38860e5676262b327aa'
AND (
token = 'r+SyZtzTiV/aZZIbYe3v2Jjsio6SE2AcYwsFyihp+z0='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)