UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = '0cYzSSTbaeosXbqvKGNWJEeVEnMcEyKtvv0G2fCs1Oo='
WHERE
key_id = '4e2d3f99fe04e4af2127d2c89e7923594538ce778c4caeace209766a3e6d0a5b'
AND (
token = '0cYzSSTbaeosXbqvKGNWJEeVEnMcEyKtvv0G2fCs1Oo='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)