UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'ldC2hwwOTONTav8QgSx1J+aXDtwRbrNODnsHg0Dsrgw='
WHERE
key_id = 'a51f728c5f4a0de80d6f770c0e829d24858c522c4d149e628d6ce4826b6eb816'
AND (
token = 'ldC2hwwOTONTav8QgSx1J+aXDtwRbrNODnsHg0Dsrgw='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)