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