UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'pMcygn+bNS6HlW+WLwCI8Sj6QPd4x9iU2q+2uRMEMME='
WHERE
key_id = 'c0517c69fa90fea22ab0fcb561ba7c258a991a28296d554d7188bc95c6d66316'
AND (
token = 'pMcygn+bNS6HlW+WLwCI8Sj6QPd4x9iU2q+2uRMEMME='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)